<template>
  <div id="eventdetails" @mouseover="showset" @mouseout="hideset" :style="{color:moddata.config.fontcolor}" class="mod">
    <div>
      <div class="con">
        <div class="title" v-show="moddata.config.titleshow">
          <span>
            <i class="iconfont icon-xiangqing"></i>&nbsp;{{moddata.config.title}}</span>
        </div>
        <div class="text summary" v-html="taskdata.Summary">
        </div>
        <div class="text">
          分享到：
          <a href="javascript:;" class="bds_weixin" title="分享到微信" @click="shareWx">微信</a>
        </div>
      </div>
    </div>
    <div class="mask" v-show="maskshow">
      <div class="settingbtn" @click="headset">
        <i class="el-icon-setting"></i> 设置</div>
      <div class="deletebtn" @click="deletemod">
        <i class="el-icon-delete"></i> 删除</div>
    </div>
  </div>
</template>

<script>
  import {
    MessageBox
  } from 'element-ui'
  export default {
    props: ["moddata", "index", "taskdata"],
    data: function () {
      return {
        maskshow: false
      }
    },
    methods: {
      showset: function () {
        this.maskshow = true;
      },
      hideset: function () {
        this.maskshow = false;
      },
      headset: function () {
        this.$store.commit({
          type: 'showsetbox',
          setMod: 'SetShowMod',
          index: this.index
        })
      },
      deletemod: function () {
        this.$store.dispatch('deleteMod', this.index)
      },
      shareWx: function () {
        const h = this.$createElement;
        var ewmUrl = window.location.protocol + "//" + window.location.host + "/Events/" + this.taskdata.TaskId;
        var qrCodeImgSrc = "/MicroSurvey/Home/GetQrCode?enCodeUrl=" + encodeURIComponent(ewmUrl);
        MessageBox({
          title: '分享到微信',
          showConfirmButton: false,
          message: h('div', null, [
            h('img', {
              attrs: {
                src: qrCodeImgSrc
              },
              style: {
                margin: 'auto',
                display: 'block'
              }
            }),
            h('p', {
              style: {
                textAlign: 'center',
                paddingTop: '20px'
              }
            }, '打开微信，点击底部的“发现”，'),
            h('p', {
              style: {
                textAlign: 'center'
              }
            }, '使用“扫一扫”即可将网页分享至朋友圈。')
          ])
        })
      }
    }
  }
</script>

<style scoped>
  .bds_weixin {
    display: inline-block;
    background: url(/Areas/Template/Content/Design/images/bdsharebuttonbox.png) no-repeat;
    background-size: 32px 288px;
    height: 32px;
    font-size: 12px;
    color: #fff;
    width: 58px;
    padding-left: 24px;
    line-height: 32px;
    text-align: center;
    box-sizing: content-box;
    border-radius: 2px;
    float: none;
    background-position: 0 -128px;
    background-color: #5bc333;
  }

  .bds_weixin:hover {
    opacity: .8;
    filter: alpha(opacity=80);
  }
</style>
<style lang="less">
  .text img {
    max-width: 100%;
  }

  #eventdetails .summary {
    word-wrap: break-word;
    cursor: text;
    font-family: sans-serif;
    font-size: 16px;
    b,
    strong {
      font-weight: bold;
    }
    i,
    em {
      font-style: italic;
    }
    p {
      margin: 5px 0;
    }
  }
</style>